package cn.wolfcode.crm.mapper;

import cn.wolfcode.crm.domain.Employee;
import cn.wolfcode.crm.qo.QueryObject;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface EmployeeMapper {
    int deleteByPrimaryKey(Long id);

    int insert(Employee record);

    Employee selectByPrimaryKey(Long id);

    List<Employee> selectAll();

    int updateByPrimaryKey(Employee record);

//    int getCount(QueryObject qo);

    List<Employee> query(QueryObject qo);

    /**
     * 删除 employee_role中间表
     *
     * @param employeeId
     */
    void deleteRelation(Long employeeId);


    /**
     * 插入 employee_role中间表
     *
     * @param employeeId
     * @param roleId
     */
    void insertRelation(@Param("employeeId") Long employeeId, @Param("roleId") Long roleId);

    /**
     * 登录功能
     *
     * @param username
     * @param password
     * @return
     */
    Employee selectByUsernameAndPassword(@Param("username") String username, @Param("password") String password);


    /**
     * 根据id数组 批量删除员工
     * @param ids
     */
    void batchDelete(Long[] ids);

    /**
     * 根据id数组 批量删除中间表关系
     * @param ids
     */
    void batchDeleteRelation(Long[] ids);

    /**
     * 根据用户名 查询员工
     * @param name
     * @return
     */
    Employee selectByName(String name);

    //根据可变的String数组
    List<Employee> selectEmployeeByRoleSn(String...sns);
}